#ifndef __WDT_H_
#define __WDT_H_

#include "sys.h"

/* WDT TIME = (12 * Pre-scale * 32768)/FOSC = Pre-scale * 393216 / FOSC */

#if (FOSC == FOSC_11_M)
/**
 * @brief wdt_tim_t - 11.0592MHz
 *
 * @param TIM_71_1_MS 71.1ms
 * @param TIM_142_2_MS 142.2ms
 * @param TIM_284_4_MS 284.4ms
 * @param TIM_568_8_MS 568.8ms
 * @param TIM_1_1_S 1.1s
 * @param TIM_2_27_S 2.27s
 * @param TIM_4_5_S 4.5s
 * @param TIM_9_1_S 9.1s
 */
typedef enum
{
    TIM_71_1_MS,
    TIM_142_2_MS,
    TIM_284_4_MS,
    TIM_568_8_MS,
    TIM_1_1_S,
    TIM_2_27_S,
    TIM_4_5_S,
    TIM_9_1_S,
} wdt_tim_t;
#elif (FOSC == FOSC_12_M)
/**
 * @brief wdt_tim_t - 12.0000MHz
 *
 * @param TIM_65_5_MS 65.5ms
 * @param TIM_131_0_MS 131.0ms
 * @param TIM_262_1_MS 262.1ms
 * @param TIM_524_2_MS 524.2ms
 * @param TIM_1_048_S 1.048s
 * @param TIM_2_097_S 2.097s
 * @param TIM_4_194_S 4.194s
 * @param TIM_8_388_S 8.388s
 */
typedef enum
{
    TIM_65_5_MS,
    TIM_131_0_MS,
    TIM_262_1_MS,
    TIM_524_2_MS,
    TIM_1_048_S,
    TIM_2_097_S,
    TIM_4_194_S,
    TIM_8_388_S,
} wdt_tim_t;
#elif (FOSC == FOSC_20_M)
/**
 * @brief wdt_tim_t - 11.0592MHz
 *
 * @param TIM_39_3_MS 39.3ms
 * @param TIM_78_6_MS 78.6ms
 * @param TIM_157_3_MS 157.3ms
 * @param TIM_314_6_MS 314.6ms
 * @param TIM_629_1_S 629.1ms
 * @param TIM_1_25_S 1.25s
 * @param TIM_2_5_S 2.5s
 * @param TIM_5_S 5s
 */
typedef enum
{
    TIM_39_3_MS,
    TIM_78_6_MS,
    TIM_157_3_MS,
    TIM_314_6_MS,
    TIM_629_1_S,
    TIM_1_25_S,
    TIM_2_5_S,
    TIM_5_S,
} wdt_tim_t;
#endif

void wdt_init(wdt_tim_t wdt_tim);
void clear_wdt(void);

#endif
